home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / CLIPVIEW.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  135 lines

  1. //--------------------------------------------------------------------
  2. // CLIPVIEW.AML
  3. // Clipboard Viewer, (C) 1993-1996 by nuText Systems
  4. //
  5. // (See Clipview.dox for user help)
  6. //
  7. // This macro displays the contents of the current clipboard.
  8. // A menu is also displayed which allows you to clear the clipboard,
  9. // paste from the clipboard, and change the current (displayed)
  10. // clipboard.
  11. //
  12. // Usage:
  13. //
  14. // Select this macro from the Macro List (on the Macro menu), or run it
  15. // from the macro picklist <shift f12>.
  16. //--------------------------------------------------------------------
  17.  
  18. include bootpath "define.aml"
  19.  
  20. // initial popup window dimensions
  21. constant view_width  = 71
  22. constant view_height = 13
  23.  
  24. // colors
  25. constant view_title_color        = color black on gray
  26. constant view_menu_color         = color white on blue
  27. constant view_menu_hotkey_color  = color yellow on blue
  28. constant view_menu_hilite_color  = color white on cyan
  29.  
  30. variable emptybuf, emptycurs, clipbuf
  31.  
  32. // inherit from the 'popup' object
  33. settype "popup"
  34.  
  35. // clear the clipboard
  36. function vclear
  37.   setwincurs
  38.   if clipbuf then
  39.     destroybuf clipbuf
  40.     clipbuf = ''
  41.   end
  42.   if not emptybuf then
  43.     emptybuf = createbuf
  44.     emptycurs = createcursor
  45.   end
  46.   setwincurs emptycurs
  47. end
  48.  
  49. // paste from the clipboard
  50. function vpaste (options)
  51.   if getwinbuf == emptybuf then
  52.     msgbox "Nothing to paste."
  53.   else
  54.     close
  55.     queue "paste" options
  56.   end
  57. end
  58.  
  59. // change the current (displayed) clipboard
  60. function vview
  61.   buffer = ask "Enter the Clipboard to view" '' (if? clipbuf clipbuf _ClipName)
  62.   if buffer
  63.     if buffer? buffer then
  64.       colormark (getpalette 6) (getcurrmark clipbuf)
  65.       clipbuf = buffer
  66.       // change the current clipboard
  67.       prf.ClipName = clipbuf
  68.       setwincurs
  69.       cursor = getcurrcurs clipbuf
  70.       if not cursor then
  71.         cursor = createcursor '' clipbuf
  72.       end
  73.       setwincurs cursor
  74.       colormark -2 (getcurrmark clipbuf)
  75.       settitle "Clipboard '" + clipbuf + "'"
  76.     else
  77.       msgbox "Clipboard '" + buffer + "' not found."
  78.     end
  79.   end
  80. end
  81.  
  82. // called when the popup window is created
  83. function onopen
  84.   colormark -2 (getcurrmark)
  85.   setcolor north_title_color  view_title_color
  86.   setcolor menu_color         view_menu_color
  87.   setcolor menu_hotkey_color  view_menu_hotkey_color
  88.   setcolor menu_hilite_color  view_menu_hilite_color
  89.   setframe "+4"
  90.   menubar '' 4
  91.     item "{Ctrl-C}=Clear"       vclear
  92.     item "{Ctrl-P}=Paste"       vpaste
  93.     item "{Ctrl-O}=Paste Over"  vpaste 'o'
  94.     item "{Ctrl-V}=View"        vview
  95.     item "{Esc}=Exit"           close
  96.   end
  97.   if (getcoord 'y') + 2 <= getvidrows then
  98.     sizewindow 0 0 0 2
  99.   end
  100.   setwinctrl "≡" 2
  101. end
  102.  
  103. // called when the popup window is destroyed
  104. function onclose
  105.   colormark (getpalette 6) (getcurrmark)
  106. end
  107.  
  108. // macro help
  109. macrofile = arg 1
  110. key <f1>
  111.   helpmacro macrofile
  112. end
  113.  
  114. key <ctrl c>  vclear
  115. key <ctrl p>  vpaste
  116. key <ctrl o>  vpaste 'o'
  117. key <ctrl v>  vview
  118. end
  119. // (<esc> is handled by 'popup' object)
  120.  
  121. if not _ClipName or not (buffer? _ClipName) then
  122.   emptybuf = createbuf
  123.   emptycurs = createcursor
  124. else
  125.   clipbuf = _ClipName
  126. end
  127.  
  128. // display the clipboard window
  129. popup (if? emptybuf emptybuf clipbuf)  "Clipboard '" + _ClipName + "'"
  130.       view_width view_height (getcurrobj)
  131.  
  132. if emptybuf then
  133.   destroybuf emptybuf
  134. end
  135.